package com.sunyard.weixi.javacookiestest;

import com.sunyard.weixi.javacookies.PropertiesUtils;
import com.sunyard.weixi.javacookies.ZipUtil;
import org.junit.Test;

import java.io.File;

/**
 * Created by xic on 2015/12/24.
 */
public class PropretiesUtilsTest {

    @Test
    public void testLoadProperties(){
        PropertiesUtils.loadProperties(PropretiesUtilsTest.class.getResource("/").getPath() + File.separator + "test.properties");
    }

    @Test
    public void deleteEmptyDir(){
//        String path = "D:\\.m2\\repository";
        String testPath = "D:\\.m2\\repository";
        this.delete(new File(testPath));
    }

    /**
     * 删除固定文件夹下的空文件夹
     * @param file
     */
    private void delete(File file) {
        if(file.isDirectory() && file.listFiles().length == 0){
            System.out.println("delete file path - " + file.getPath());
            file.delete();
        }
        if(file.isDirectory() && file.listFiles().length != 0){
            System.out.println("current dir path : " + file.getPath());
            File[] files = file.listFiles();
            for(File file1 : files){
                delete(file1);
            }
        }
    }

    @Test
    public void testUnzip(){
        ZipUtil.unzip("d:\\test.zip", "d:\\test");
    }

}
